import React from 'react';
import { useLoaderData } from 'react-router-dom';
import Nav from '../component/nav';

export const loader = () => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        name: '这里是主页',
      });
    }, 500);
  });
};

export default () => {
  const { name } = useLoaderData();

  const handleClick = () => {
    console.log('home');
  };

  return (
    <>
      <Nav></Nav>
      <h1 onClick={handleClick}>{name}</h1>
    </>
  );
};
